VintaSoft Imaging .NET SDK 14.0: Documentation for .NET developer
Vintasoft.Imaging.Codecs.ImageFiles.Raw Namespace / Cr2Page Class / GetRawPreviewImage Methods / GetRawPreviewImage(EventHandler<ProgressEventArgs>) Method
Syntax Example Requirements SeeAlso
In This Topic
    GetRawPreviewImage(EventHandler<ProgressEventArgs>) Method (Cr2Page)
    In This Topic
    Returns a RAW preview image associated with this Cr2 page.
    Syntax

    Parameters

    progressDelegate
    Progress delegate.

    Return Value

    The RAW preview image associated with this ImagePage object if RAW preview image was loaded successfully; otherwise, null.
    Example

    Here is an example that shows how to open Canon CR2-file, get preview image from CR2-file and save image to a PNG-file:

    
    ''' <summary>
    ''' Opens Canon CR2-file, gets RAW preview image from CR2-file and saves image to a PNG-file.
    ''' </summary>
    ''' <param name="cr2Filename">The name of CR2-file.</param>
    Public Sub GetAndSaveCr2RawPreviewImage(cr2Filename As String)
        ' open CR2-file stream
        Using fs As New System.IO.FileStream(cr2Filename, System.IO.FileMode.Open, System.IO.FileAccess.Read)
            ' open CR2-file
            Dim rawImageFile As New Vintasoft.Imaging.Codecs.ImageFiles.Raw.RawImageFile(fs)
            ' get CR2-page
            Dim cr2Page As Vintasoft.Imaging.Codecs.ImageFiles.Raw.Cr2Page = TryCast(rawImageFile.Page, Vintasoft.Imaging.Codecs.ImageFiles.Raw.Cr2Page)
            ' if CR2-page is found in RAW-file
            If cr2Page IsNot Nothing Then
                ' get RAW preview image image from CR2-file
                Using rawPreviewImage As Vintasoft.Imaging.VintasoftImage = cr2Page.GetRawPreviewImage()
                    ' save image to a PNG file
                    rawPreviewImage.Save(cr2Filename & ".png")
                End Using
            End If
        End Using
    End Sub
    
    
    
    /// <summary>
    /// Opens Canon CR2-file, gets RAW preview image from CR2-file and saves image to a PNG-file.
    /// </summary>
    /// <param name="cr2Filename">The name of CR2-file.</param>
    public void GetAndSaveCr2RawPreviewImage(string cr2Filename)
    {
        // open CR2-file stream
        using (System.IO.FileStream fs = new System.IO.FileStream(cr2Filename, System.IO.FileMode.Open, System.IO.FileAccess.Read))
        {
            // open CR2-file
            Vintasoft.Imaging.Codecs.ImageFiles.Raw.RawImageFile rawImageFile =
                new Vintasoft.Imaging.Codecs.ImageFiles.Raw.RawImageFile(fs);
            // get CR2-page
            Vintasoft.Imaging.Codecs.ImageFiles.Raw.Cr2Page cr2Page =
                rawImageFile.Page as Vintasoft.Imaging.Codecs.ImageFiles.Raw.Cr2Page;
            // if CR2-page is found in RAW-file
            if (cr2Page != null)
            {
                // get RAW preview image image from CR2-file
                using (Vintasoft.Imaging.VintasoftImage rawPreviewImage = cr2Page.GetRawPreviewImage())
                {
                    // save image to a PNG file
                    rawPreviewImage.Save(cr2Filename + ".png");
                }
            }
        }
    }
    
    

    Requirements

    Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also